package com.app.mingluxing.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.app.mingluxing.R;
import com.app.mingluxing.base.BaseActivity;
import com.app.mingluxing.my.CreateBabySpaceActivity;
import com.app.mingluxing.my.EntryCodeActivity;

/**
 * 未绑定过宝宝,
 * Created by Aaron on 15/11/19.
 */
public class BindChildActivity extends BaseActivity {

    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_baby);
        init();
    }

    private void init() {

        ImageView iv_left = (ImageView) findViewById(R.id.iv_left);
        iv_left.setVisibility(View.INVISIBLE); //不显示回退按钮

        TextView tv_title = (TextView) findViewById(R.id.tv_title);
        tv_title.setText(getResources().getString(R.string.add_baby));
        TextView tv_entrybaby_code= (TextView) findViewById(R.id.tv_entrybaby_code);
        TextView tv_createbaby_space= (TextView) findViewById(R.id.tv_createbaby_space);

        tv_createbaby_space.setOnClickListener(this);
        tv_entrybaby_code.setOnClickListener(this);

    }

    @Override
    public void widgetClick(View v) {

        switch (v.getId()){

            case R.id.tv_entrybaby_code:

                intent = new Intent(this,EntryCodeActivity.class);
                startActivity(intent);
                break;

            case R.id.tv_createbaby_space:

                intent = new Intent(this,CreateBabySpaceActivity.class);
                startActivity(intent);
                break;
        }
    }

    private long mPressedTime = 0;

    @Override
    public void onBackPressed() {
//        super.onBackPressed();

        long mNowTime = System.currentTimeMillis();//获取第一次按键时间

        if ((mNowTime - mPressedTime) > 2000) {//比较两次按键时间差

            showToast("再按一次退出程序");

            mPressedTime = mNowTime;

        } else {//退出程序

            finish();
            mApplication.exit();
        }

    }
}
